package org.example.clue.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import org.example.Result;
import org.example.clue.entity.Clue;
import org.example.clue.service.IClueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 线索 前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2023-06-28
 */
@RestController
@RequestMapping("/clue")
@RefreshScope
@CrossOrigin(origins = "http://localhost:63342")
public class ClueController {
    @Autowired
    private IClueService service;
//    @Value("${server.port}")00
//    private int port;
//    @Value("${clue.id.min}")
//    private int min;
//    @Value("${clue.id.max}")
//    private int max;
//    @Value("${clue.name}")
//    private String name;
//
//    @Value("${cache.time}")
//    private int timeout;
    @SentinelResource(value = "clues.get",blockHandler = "blockGet")
    @GetMapping
    public Result<List<Clue>> getAll(){
//        System.out.println(max);
//        System.out.println(min);
//        System.out.println(port);
//        System.out.println(name);
//        System.out.println(timeout);
        return Result.ok(service.list());
    }
    public  Result<List<Clue>> blockGet(BlockException exception){
        return Result.error("别你妈点了曹尼玛");
    }
}